import 'package:enterprise_v6_app/app/components/custom_refresh.dart';
import 'package:enterprise_v6_app/app/core/core.dart';
import 'package:enterprise_v6_app/app/core/http/http.dart';
import 'package:enterprise_v6_app/app/core/utils/interface.dart';
import 'package:enterprise_v6_app/app/data/entities/application/education/teacher_power/lecturer_list_page_entity.dart';

///师资力量
class TeacherPowerController extends GetxController {
  /// 列表刷新key
  final GlobalKey<CustomEasyRefreshListState> globalKey = GlobalKey();

  /// 筛选右侧栏控制Key
  final riskRightScaffoldKey = GlobalKey<ScaffoldState>();

  Future<List<LecturerListPageEntity>> listPage(int index, int size, {String? search}) async {
    final res = await HttpUtil().generateGetRequest<List<LecturerListPageEntity>>(
      Interface.listPage,
      queryParameters: {
        'pageNum': index,
        'pageSize': size,
        // 'lecturerName': '',//	讲师姓名
        // 'lecturerTypeDicId': '',//	讲师类型字典ID
      },
    ).execute();
    List<LecturerListPageEntity>? list = [];
    res.onSuccess((result) {
      if (result.data != null) {
        list = result.data;
      }
    });
    return list!;
  }

  //师资力量点赞
  void onClickTrainLikeTeacher(String? id) async {
    final res = await HttpUtil().generateGetRequest(
      Interface.likeOrCleanLike,
      queryParameters: {'id': id},
    ).execute();
    res.onSuccess((result) {
      globalKey.currentState?.onRefresh();
    });
    update();
  }
}
